package com.example.springboottools.utils.image;
import gui.ava.html.image.generator.HtmlImageGenerator;
import gui.ava.html.parser.HtmlParser;
import gui.ava.html.parser.HtmlParserImpl;
import gui.ava.html.renderer.ImageRenderer;
import gui.ava.html.renderer.ImageRendererImpl;

import java.io.File;

/**
 * 引用https://blog.csdn.net/qq_25775675/article/details/106672855?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-1-106672855-blog-139976316.235%5Ev43%5Epc_blog_bottom_relevance_base5&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-1-106672855-blog-139976316.235%5Ev43%5Epc_blog_bottom_relevance_base5&utm_relevant_index=1
 */
public class HtmlToPicUtilZss {

    public static void main(String[] args) {
        guiAvaToPic(htmlTemplate);
    }

    /**
     * 有失败的，
     * @param htmlTemplate
     */
    public static void githubXuWeiToPic(String htmlTemplate) {
        HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
        //加载html模版
        imageGenerator.loadHtml(htmlTemplate);
        //把html写入到图片
        imageGenerator.saveAsImage("D:\\staples\\日常记录\\工作记录\\2024\\08\\0815\\pic\\githubXuWeiToPic3.png");
    }

    /**
     * 推荐
     * @param htmlTemplate
     */
    public static void guiAvaToPic(String htmlTemplate) {
        HtmlParser htmlParser = new HtmlParserImpl();
        htmlParser.loadHtml(htmlTemplate);
        // html 是我的html代码
        ImageRenderer imageRenderer = new ImageRendererImpl(htmlParser);
        imageRenderer.saveImage("D:\\staples\\日常记录\\工作记录\\2024\\08\\0815\\pic\\guiAvaToPic5.png");
        //把html写入到图片
    }

    static String htmlTemplate = "桌面";
}
